package xyz.yuzegod.megawalls.classes.novice.him;

import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import xyz.yuzegod.megawalls.classes.Classes;
import xyz.yuzegod.megawalls.classes.Skill;
import xyz.yuzegod.megawalls.game.GamePlayer;
import xyz.yuzegod.megawalls.stats.KitStatsContainer;

import java.util.ArrayList;
import java.util.List;

public class SecondSkill extends Skill
{
    public SecondSkill(final Classes classes) {
        super("力量", classes);
    }
    
    @Override
    public int maxedLevel() {
        return 3;
    }
    
    @Override
    public double getAttribute(final int level) {
        switch (level) {
            case 1: {
                return 4.0;
            }
            case 2: {
                return 5.0;
            }
            case 3: {
                return 6.0;
            }
            default: {
                return 4.0;
            }
        }
    }
    
    @Override
    public List<String> getInfo(final int level) {
        final List<String> lore = new ArrayList<String>();
        if (level == 1) {
            lore.add(" §8▪ §7击杀一名敌人后,获得85%的近战");
            lore.add("   §7伤害加成,持续§a" + this.getAttribute(level) + "§7秒。");
            return lore;
        }
        lore.add(" §8▪ §7击杀一名敌人后,获得85%的近战");
        lore.add("   §7伤害加成,持续§8" + this.getAttribute(level - 1) + " ➜ §a" + this.getAttribute(level) + "§7秒。");
        return lore;
    }
    
    @Override
    public void upgrade(final GamePlayer gamePlayer) {
        final KitStatsContainer kitStats = gamePlayer.getPlayerStats().getKitStats(this.getClasses());
        kitStats.addSkill2Level();
    }
    
    @Override
    public int getPlayerLevel(final GamePlayer gamePlayer) {
        return gamePlayer.getPlayerStats().getKitStats(this.getClasses()).getSkill2Level();
    }
    
    @Override
    public boolean use(final GamePlayer gamePlayer, final KitStatsContainer kitStats) {
        if (HIM.skill2.getOrDefault(gamePlayer, 0) > 0) {
            return false;
        }
        gamePlayer.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, (int)(this.getAttribute(this.getPlayerLevel(gamePlayer)) * 20.0), 0));
        HIM.skill2.put(gamePlayer, (int)this.getAttribute(kitStats.getSkill2Level()));
        return true;
    }
    
    @Override
    public String getSkillTip(final GamePlayer gamePlayer) {
        final int seconds = HIM.skill2.getOrDefault(gamePlayer, 0);
        return this.getClasses().getNameColor() + "§l" + this.getName() + " §c§l85%" + seconds + "秒";
    }
}
